package com.fengkai.filepost.pdfoutstream.test.ODsolutions;

/**
 * @author Fengkai  最小字符交换字符
 * @creat 2023/3/30
 */
public class ChageMinCharIndex {

       public static void main(String[] args){
           System.out.println(getResult("bcdefa"));

          }


    public static String getResult(String input){
        char[] chars = input.toCharArray();
        int min = Integer.MAX_VALUE;
        int index = 0;
        for (int i = 0; i < chars.length ; i++) {
            if (min > (int) chars[i]){
                min = (int)chars[i];
                index = i;
            }
        }
        if (index != 0){
            chars[0] ^= chars[index];
            chars[index] ^= chars[0];
            chars[0] ^= chars[index];
        }
        return new String(chars);
    }

}
